﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsBlockReferenceNodeImpl : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsBlockReferenceNodeImpl(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsBlockReferenceNodeImpl obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.deletePD_OdGsBlockReferenceNodeImpl(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public virtual bool invalidate(OdGsContainerNode pParent, OdGsViewImpl pView, uint mask)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_invalidate(this.swigCPtr, OdGsContainerNode.getCPtr(pParent), OdGsViewImpl.getCPtr(pView), mask);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool destroy()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_destroy(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool destroySubitems()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_destroySubitems(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool select(OdGsBaseVectorizer view, OdSiRecursiveVisitor pVisitor, bool bHasExtents, OdGsView.SelectionMode mode)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_select(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdSiRecursiveVisitor.getCPtr(pVisitor), bHasExtents, (int)mode);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void highlight(bool bDoIt, bool bWholeBranch)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_highlight(this.swigCPtr, bDoIt, bWholeBranch);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGsEntityNode firstEntity()
		{
			OdGsEntityNode result = (OdGsEntityNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_firstEntity(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void playAsGeometry(OdGsBaseVectorizer view, EMetafilePlayMode eMode)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_playAsGeometry(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), (int)eMode);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isSharedReference()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_isSharedReference(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isSharedDefinition()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_isSharedDefinition(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool layersChanged(OdGsViewImpl view)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_layersChanged(this.swigCPtr, OdGsViewImpl.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void makeStock()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_makeStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void releaseStock()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_releaseStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void propagateLayerChangesStock()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_propagateLayerChangesStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void doSpatialQuery(SWIGTYPE_p_OdGsSpQueryContext ctx)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_doSpatialQuery(this.swigCPtr, SWIGTYPE_p_OdGsSpQueryContext.getCPtr(ctx));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool saveNodeImplState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_saveNodeImplState(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool loadNodeImplState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer, OdGsBaseModel pModel)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_loadNodeImplState(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer), OdGsBaseModel.getCPtr(pModel));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void postprocessNodeImplLoading(SWIGTYPE_p_OdGsFiler arg0)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNodeImpl_postprocessNodeImplLoading(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(arg0));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;
	}
}
